//
//  UserDefaultManager.swift
//  mmda
//
//  Created by 李陆涛 on 2018/4/25.
//  Copyright © 2018年 mmda. All rights reserved.
//

import UIKit

class UserDefaultManager: NSObject {

    static let share = UserDefaultManager()
    private override init() {}

    
    private var secret:String?
    private var mobile:String?
    
    
    func setSecret(secret:String?) {
        
        self.secret = secret
        
        UserDefaults.standard.set(secret, forKey: "unLoginSecret")
        UserDefaults.standard.synchronize()
    }
    
    func getSecret() -> String? {
        
        guard let secret = self.secret else {
            
            return UserDefaults.standard.string(forKey: "unLoginSecret")
        }
        
        return secret
    }
    
    
    func setMobile(mobile:String?) {
        
        self.mobile = mobile
        
        UserDefaults.standard.set(mobile, forKey: "loginPhoneNum")
        UserDefaults.standard.synchronize()
    }
    
    func getMobile() -> String? {
        
        guard let mobile = self.mobile else {
            
            return UserDefaults.standard.string(forKey: "loginPhoneNum")
        }
        
        return mobile
    }
    
    func setCode(mobile:String,code:String?) {
        
        UserDefaults.standard.set(code, forKey: mobile)
        UserDefaults.standard.synchronize()
        
    }
    
    func getCode(mobile:String) -> String? {
    
        return UserDefaults.standard.string(forKey: mobile)
    }
    
    func setHasAgree(argee:Bool) {
        
        UserDefaults.standard.set(argee, forKey: "hasAgreement")
        UserDefaults.standard.synchronize()
    }
    
    func hasAgree() -> Bool {
        return UserDefaults.standard.bool(forKey: "hasAgreement")
    }
    
    
}
